<%@ page import="com.yhp.bean.Users" %>
<%@ page import="java.util.List" %>
<%@ page import="com.yhp.util.PageUtilPlus" %>
<%@ page import="com.yhp.util.PeopleUtil" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>UserList</title>
    <style type="text/css">
        span{ border: 1px solid black}
        a{ text-decoration: none}
    </style>
</head>
<body>
    <h1>list.jsp，,欢迎您:${sessionScope.u1.userName}；当前在线人数<%=PeopleUtil.PEOPLE_ON_LINE%>
        <a href="/usersServlet?key=loginout">退出</a>
    </h1>

    <div><input type="button" value="新增" onclick="javascript:location.href='add.jsp'"></div>
     <div>
          <form action="/usersServlet?key=selectusers" method="post">
              姓名:<input type="text" name="uname" value="${username}">&nbsp;&nbsp;&nbsp;&nbsp;
              性别: <select name="usex">
                            <option value="noselect" ${usersex=="noselect"?"selected":""}>请选择</option>
                            <option value="男" ${usersex=="男"?"selected":""}>男</option>
                            <option value="女" ${usersex=="女"?"selected":""}>女</option>
                    </select>
                <input type="submit" value="查询"/>
          </form>

     </div>
    <table border="1" cellspacing="0" width="500">
        <tr>
            <td>用户编号</td>
            <td>用户姓名</td>
            <td>用户性别</td>
            <td>用户年龄</td>
            <td>用户密码</td>
            <td>操作</td>
        </tr>

        <c:forEach items="${pu.dataList}" var="u">
            <tr>
                <td>${u.userId}</td>
                <td>${u.userName}</td>
                <td>${u.sex}</td>
                <td>${u.age}</td>
                <td>${u.passWord}</td>
                <td> <a href="/usersServlet?key=deleteuser&userid=${u.userId}">删除</a>
                    <a href="/usersServlet?key=deletebyid&userid=${u.userId}">假删除</a>
                    <a href="/usersServlet?key=selectbyid&userid=${u.userId}">修改</a>  </td>
            </tr>
        </c:forEach>
        <tr>
            <td colspan="6">
                <a href="/usersServlet?key=selectusers&pageindex=1&uname=${username}&usex=${usersex}">首页</a>
                <a href="/usersServlet?key=selectusers&pageindex=${pu.pageIndex-1<=1?1:pu.pageIndex-1}&uname=${username}&usex=${usersex}">上一页</a>

                <c:forEach begin="1" end="${pu.totalPages}" var="i" >
                <a href="/usersServlet?key=selectusers&pageindex=${i}&uname=${username}&usex=${usersex}"><span>${i}</span></a> &nbsp;&nbsp;
                </c:forEach>

                <a href="/usersServlet?key=selectusers&pageindex=${pu.pageIndex+1>=pu.totalPages?pu.totalPages:pu.pageIndex+1}&uname=${username}&usex=${usersex}">下一页</a>
                <a href="/usersServlet?key=selectusers&pageindex=${pu.totalPages}&uname=${username}&usex=${usersex}">尾页</a>
                <br>
                当前页:${pu.pageIndex},
                总页数:${pu.totalPages},
                总条数:${pu.totalCount}
            </td>
        </tr>
    </table>


</body>
</html>
